﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using YWTSSys.DAL;
using YWTSSys.Model;
using YWTSSys.Library;
using System.Data;

namespace YWTSSys.BLL
{
    public class CustomerController
    {
        /// <summary>
        /// 添加新客户
	    ///说明：
		///自动根据区域标记获取所在的默认组
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static int Add(CustomerInfo obj)
        {
            return CustomerDAL.Add(obj);
        }
        /// <summary>
        /// 根据客户名称，手机号码，会员卡号 查询客户信息，一次最多显示20条
        /// </summary>
        /// <param name="SqlWhere"></param>
        /// <returns></returns>
        public static DataTable GetByWhereTop20(string SqlWhere, string Sort)
        {
            return CustomerDAL.GetByWhereTop20(SqlWhere, Sort);
        }
        /// <summary>
        /// 获取客户信息根据ID
        /// </summary>
        /// <param name="客户Id"></param>
        /// <returns></returns>
        public static CustomerInfo GetById(int 客户Id)
        {
            return CBO.FillObject<CustomerInfo>( CustomerDAL.GetById(客户Id));
        }
        /// <summary>
        /// 业务员获取其所属的客户列表
        /// </summary>
        /// <param name="UserId"></param>
        /// <param name="WhereSql"></param>
        /// <param name="PageIndex"></param>
        /// <param name="PageSize"></param>
        /// <param name="Sort"></param>
        /// <param name="TotalCount"></param>
        /// <returns></returns>
        public static DataTable GetMyCustomerPagination(int UserId, string WhereSql, int PageIndex, int PageSize, string Sort, ref int TotalCount)
        {
            return CustomerDAL.GetMyCustomerPagination(UserId,WhereSql, PageIndex, PageSize, Sort, ref  TotalCount);
        }

        /// <summary>
        /// 重置指定分组的客户电话拔打状态为 未拔打
        /// </summary>
        /// <param name="GroupName"></param>
        /// <returns></returns>
        public static bool Customer_ChangeTelStatus(string GroupName)
        {
            return CustomerDAL.Customer_ChangeTelStatus(GroupName);
        }
    }
}
